﻿//正则表达式
layui.use(['jquery', 'ajaxUtil', 'layedit', 'dialog', 'permissionUtil'], function () {
    var $ = layui.jquery
        , ajaxutil = layui.ajaxUtil
        , layedit = layui.layedit
        , dialog = layui.dialog
        , permissionUtil = layui.permissionUtil;
    //permissionUtil.setting(150020);

    var init = function () {
        initBtnEvent();
    }

    var initBtnEvent = function () {
        $(".btn_regex_match").unbind("click");
        $(".btn_regex_match").bind("click", function () {
            //获取data-regexPattern内容
            var pattern = $(this).attr("data-regexPattern");
            console.log(pattern);
            ajaxutil.request({
                url: '/communicate/regex/getmatchpattern'
                , data: {
                    RegexPattern: pattern
                }
                , success: function (res) {
                    $("#txt_Communicate_RegexContent").val(res.data);
                }
            });
        });

        //测试匹配
        $('#btn_Communicate_GetResult').unbind("click");
        $("#btn_Communicate_GetResult").bind("click", function (e) {
            $("#txt_Communicate_Result").val('');

            var regexContent = $("#txt_Communicate_RegexContent").val();
            var textContent = $("#txt_Communicate_TextContent").val();
            ajaxutil.request({
                url: '/communicate/regex/ismatch'
                , data: {
                    RegexPattern: regexContent,
                    TextContent: textContent
                }
                , success: function (res) {
                    $("#txt_Communicate_Result").val(res.msg);
                }
            });
        });
    }

    init();
});